Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
The SPARQL 1.1 Query Language allows to query datasources of RDF triples. SPARQL.js translates SPARQL into JSON and back, so you can parse and build SPARQL queries in your JavaScript applications.
It fully supports the SPARQL 1.1 specification, including property paths, federation, and updates.
// Parse a SPARQL query to a JSON object
var SparqlParser = require('sparqljs').Parser;
var parser = new SparqlParser();
var parsedQuery = parser.parse(
'PREFIX foaf: <http://xmlns.com/foaf/0.1/> ' +
'SELECT * { ?mickey foaf:name "Mickey Mouse"@en; foaf:knows ?other. }');
// Regenerate a SPARQL query from a JSON object
var SparqlGenerator = require('sparqljs').Generator;
var generator = new SparqlGenerator();
parsedQuery.variables = ['?mickey'];
var generatedQuery = generator.stringify(parsedQuery);
$ sparql-to-json query.sparql
Queries are represented in a JSON structure. The most easy way to get acquainted with this structure is to try the examples in the queries
folder through sparql-to-json
. All examples of the SPARQL 1.1 specification have been included, in case you wonder how a specific syntactical construct is represented.
Here is a simple query in SPARQL:
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT ?p ?c WHERE {
?p a dbpedia-owl:Artist.
?p dbpedia-owl:birthPlace ?c.
?c <http://xmlns.com/foaf/0.1/name> "York"@en.
}
And here is the same query in JSON:
{
"type": "query",
"prefixes": {
"dbpedia-owl": "http://dbpedia.org/ontology/"
},
"queryType": "SELECT",
"variables": [ "?p", "?c" ],
"where": [
{
"type": "bgp",
"triples": [
{
"subject": "?p",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"object": "http://dbpedia.org/ontology/Artist"
},
{
"subject": "?p",
"predicate": "http://dbpedia.org/ontology/birthPlace",
"object": "?c"
},
{
"subject": "?c",
"predicate": "http://xmlns.com/foaf/0.1/name",
"object": "\"York\"@en"
}
]
}
]
}
The representation of triples is the same as in N3.js 0.x, but will switch to RDF/JS representation in the future.
$ [sudo] npm [-g] install sparqljs
The SPARQL.js library is copyrighted by Ruben Verborgh and released under the MIT License.
Contributions are welcome, and bug reports or pull requests are always helpful.
FAQs
A parser for the SPARQL query language
The npm package sparqljs receives a total of 4,476 weekly downloads. As such, sparqljs popularity was classified as popular.
We found that sparqljs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.